package com.riguz.springcloud;

import com.riguz.springcloud.model.Post;
import com.riguz.springcloud.service.PostService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/")
public class PostController {
    private static final Logger logger = LoggerFactory.getLogger(PostController.class);
    @Autowired
    private PostService postService;

    @GetMapping("/ping")
    public String ping() {
        return "Post Service V1.0";
    }

    @GetMapping("/post/{id}")
    public Post getPostById(@PathVariable("id") String id) {
        return  postService.findPostById(id);
    }
}
